using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace AspWebUtilities.Farm
{
	
	public partial class FarmApplicationState
	{
		Hashtable Datas = new Hashtable();

		public Object this[String DataName]
		{
			get
			{
				if(Datas[DataName] != null)
				{
					FarmData vv = (FarmData)Datas[DataName];
					vv.Update();
					return vv.Value;
				}
				else
				{
					FarmData vv = new FarmData(DataName);
					if(vv.Value != null)
						Datas.Add(DataName,vv);
					return vv.Value;
				}
			}
			set
			{
				FarmData vv = (FarmData)Datas[DataName];

				if (value == null)	//Delete From Server
				{
					if (vv != null)
					{
						vv.Remove();
						Datas.Remove(DataName);
					}
					else
					{
						FarmData.Remove(DataName);
					}
				}
				else
				{
					if (vv != null)
					{
						vv.Update(value);
					}
					else
					{
						Datas.Add(DataName, new FarmData(value, DataName));
					}
				}
			}
		}
	}
}
